using System;
using System.Collections.Generic;
using System.Xml.Linq;
using converter.template;

namespace converter
{
	// Embedded images parsing methods.
	public sealed partial class RdlFile
	{
        // Find EmbeddedImage elements, create EmbeddedImage objects, and add them to the template.
	    private void ParseEmbeddedImages(XDocument xdoc, XNamespace xmlns, Template template)
	    {
			IEnumerable<XElement> imageList = xdoc.Root.Descendants(NsName("EmbeddedImage"));
	        foreach (XElement image in imageList)
	        {
	            string name = (string)image.Attribute("Name");
	            string mimeType = (string)image.Element(xmlns + "MIMEType");
	            string data = (string)image.Element(xmlns + "ImageData");

	            template.AddEmbeddedImage(new EmbeddedImage(name, mimeType, data));
	        }
	    }
	}
}